package me.zhengjie.org.employeechange.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.hr.employeebase.domain.EmployeeBase;
import me.zhengjie.org.centerbase.domain.CenterBase;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @author ZGZ
* @date 2020-04-14
*/
@Entity
@Data
@Table(name="employee_change")
public class EmployeeChange implements Serializable {

    /** ID */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    /** 员工 */
//    @Column(name = "emp_id")
//    private Integer empId;
//    @OneToOne
//    @JoinColumn(name = "emp_id")
//    private EmployeeBase empId;
    @Column(name = "emp_id")
    private Integer empId;
    @OneToOne
    @JoinColumn(name = "emp_id", insertable = false, updatable = false)
    private EmployeeBase employeeBaseId;

    /** 原中心 */
//    @Column(name = "from_center_id")
//    private Integer fromCenterId;
//    @OneToOne
//    @JoinColumn(name = "from_center_id")
//    private CenterBase fromCenterId;
    @Column(name = "from_center_id")
    private Integer fromCenterId;
    @OneToOne
    @JoinColumn(name = "from_center_id", insertable = false, updatable = false)
    private CenterBase centerBaseFromCenterId;

    /** 新中心 */
//    @Column(name = "to_center_id")
//    private Integer toCenterId;
//    @OneToOne
//    @JoinColumn(name = "to_center_id")
//    private CenterBase toCenterId;
    @Column(name = "to_center_id")
    private Integer toCenterId;
    @OneToOne
    @JoinColumn(name = "to_center_id", insertable = false, updatable = false)
    private CenterBase centerBaseToCenterId;

    /** 变动时间 */
    @Column(name = "change_time")
    private Timestamp changeTime;

    /** 变动说明 */
    @Column(name = "`describe`")
    private String describe;

    public Integer get_Id()
    {
        return id;
    }

    public Integer get_empId()
    {
        return empId;
    }

    public Integer get_fromCenterId()
    {
        return fromCenterId;
    }
    public Integer get_toCenterId()
    {
        return toCenterId;
    }
    public Timestamp get_changeTime()
    {
        return changeTime;
    }

    public String get_describe()
    {
        return describe;
    }

    public void copy(EmployeeChange source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}